﻿<%@ Page
    autoEventWireup="true"
    classname="Client"
    enableSessionState="false"
    enableViewState="false"
    language="C#"
    trace="false"
%>

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link href="<%# cssRoot %>" rel="StyleSheet" type="text/css" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script language="C#" runat="server">

            internal string cssRoot;
            internal string root;

            protected void Page_Load(Object sender,EventArgs e) 
            {
                string title = "Web Application Exception";
                string serverName = Request.ServerVariables["SERVER_NAME"];
                string errPath = Request.QueryString["aspxerrorpath"];
                string errMsg = String.Empty;

                //Look for a server-generated query string:
                string errCode = (Request.QueryString.Count > 0)? Request.QueryString[0] : String.Empty;
                if(errCode != String.Empty)
                {
                    //Parse server-generated query string:
                    if(errCode.IndexOf(";") != -1)
                    {
                        string[] s = errCode.Split(new char[] {';'});
                        if(s.Length == 2)
                        {
                            errCode = s[0];
                            title = String.Format("Web Application Exception{0}", String.Concat(" [",errCode,"]"));
                            if(errPath == null)errPath = s[1];
                        }
                    }
                }

                switch(errCode)
                {
                    case "401":
                        errMsg = "You are not authorized to view the requested resource.";
                        break;

                    case "403":
                        errMsg = "You are not authorized to view the requested resource.";
                        break;

                    case "404":
                        errMsg = String.Concat("The requested resource ", errPath, " was not found.");
                        break;

                    default:
                        if(errPath == null)
                        {
                            errPath = String.Empty;
                            errMsg = String.Concat("The requested resource ", "produced an error.");
                        }
                        else
                        {
                            errPath = String.Concat("The requested resource ",errPath);
                            errMsg = String.Format("{0} produced an error.",errPath);
                        }
                        break;
                }

                ErrorMsg.InnerText = errMsg;

                root = String.Format("http://{0}/",serverName);
                cssRoot = String.Format("http://{0}/css/exception.css",serverName);

                Header.Title = title;

                DataBind();
            }

        </script>
        <title id="Title" runat="server"></title>
    </head>
    <body id="MainBody" runat="server">
        <div>
            <p>An unhandled Exception or Request caused this page to appear.</p>
            <p>Return to <a href="<%# root %>">the Home page</a> of this server or try the Request again.</p>            
        </div>
        <div class="ServerError" id="ErrorMsg" runat="server"></div>
    </body>
</html>
